<template>
  <div>
    <van-index-bar>
      <div v-for="(arr, key) in cityObj" :key="key">
        <van-index-anchor :index="key" />
        <van-cell v-for="item in arr" :key="item.code" :title="item.name" @click="tocitys(item.name)" />
      </div>
    </van-index-bar>
  </div>
</template>

<script>
import axios from "axios";
export default {
  data() {
    return {
      cityObj: {},
    };
  },
  async created() {
    let res = await axios.get("/api/lists");
    this.cityObj = JSON.parse(JSON.stringify(res.data.sortObj));
  },
  methods: {
    tocitys(name){
      localStorage.setItem('city',name)
      this.$router.go(-1)
    }
  },
};
</script>

<style>
</style>